<?php
	include("includes/connect.php");
	include("includes/function.php");


	$tablename = $_POST["tablename"];
	$dd = $_POST["dd"];
	$fieldname = $_POST["fieldname"];
	$idname = $_POST["idname"];

	//$dd_expend_type = $_POST["dd_expend_type"];

	$db = new myDBS;

	$result = $db->showData($tablename);
?>
<script type="text/javascript">
	$(document).ready(function(){
		$( "#dd_expend_type" ).change(function() {
			var by= $(this).val();

			if (by != "เลือก...") {
				$.post('dropdown1.php', {  tablename: 'expend_sub', dd: 'dd_expend_sub_type', idname: 'expend_sub_id', fieldname: 'expend_sub_type', by: by}, function(data) { $("#expend_sub_type").html(data); } );
			}

		});
	});
</script>
<select class="span12" id="<?php echo $dd; ?>" name="<?php echo $dd; ?>" >
	<option>เลือก...</option>
	<?php
		while ( $rows = $db->fetch_object ( $result )){
	?>
	<option value="<?php echo $rows->{$idname}; ?>"><?php echo $rows->{$fieldname}; ?></option>
	<?php } ?>
</select>